﻿using System;
using System.Windows.Forms;
using System.Collections;


namespace PuppetMaster.Menus
{
    public partial class ReservationStarter : Form
    {
        public String ClientsToinvite;
        public String ReservationName;
        public ArrayList SlotList;

        public ReservationStarter()
        {
            InitializeComponent();

            ClientsToinvite = null;
            ReservationName = null;
            SlotList = null;

            for (int index = 1; index <= 8760; index++)
            {
                timeSlots.Items.Add(index);
            }
        }

        private void makeReservation_Click(object sender, EventArgs e)
        {
            if (invitedUsers.Text.Length == 0)
            {
                MessageBox.Show("No client were selected to be invited to the reservation.");
                return;
            }
            if (reservationDesc.Text.Length == 0)
            {
                MessageBox.Show("Please enter a reservation description.");
                return;
            }

            ArrayList slotList = new ArrayList();
            CheckedListBox.CheckedItemCollection reservationSlots = timeSlots.CheckedItems;

            if (reservationSlots.Count == 0)
            {
                MessageBox.Show("Please select at least one slot.");
                return;
            }

            for (int index = 0; index < reservationSlots.Count; index++)
            {
                slotList.Add(reservationSlots[index]);
            }

            ClientsToinvite = invitedUsers.Text;
            ReservationName = reservationDesc.Text;
            SlotList = slotList;

            this.Close();
        }

        private void ReservationStarter_Closing(Object sender, EventArgs e)
        {
            if (ClientsToinvite == null && ReservationName == null && SlotList == null)
                this.DialogResult = DialogResult.Cancel;
            else
                this.DialogResult = DialogResult.OK;
        }

    }
}
